﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AlmaDatabase;

namespace Alma.Models
{
    public class SectionDetailsModel
    {
        public long ID { get; set; }
        public long? ID_Category { get; set; }
        public string Name { get; set; }
        public string Name_Category { get; set; }
        public int? Location { get; set; }
        public List<ProductDetailsModel> productList { get; set; }

        public SectionDetailsModel()
        {
        }

        public SectionDetailsModel(Section section)
        {
            ID = section.ID;
            Name = section.Name;
            ID_Category = section.ID_Category;
            Location = section.Location;
            using (var entities = new AlmaDBEntities())
            {
                foreach (var cat in (from p in entities.Categories where ID_Category == p.ID select p))
                {
                    Name_Category = cat.Name;
                }
            }
        }
    }

    public class SectionListModel
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public List<SectionDetailsModel> List { get; set; }
    }
}